import time
from pywinauto.application import Application

#启动应用程序
# Application(backend="uia").start("notepad.exe")
# time.sleep(3)
# app = Application(backend="uia").connect(title_re=".*Notepad")
# #获取窗口
# notepad = app.window(title_re=".*Notepad")
# #操作控件
# #输入文本
# notepad.Document.type_keys("Hello, Pywinauto!")
# #关闭应用程序
# notepad.close()


#start启动应用程序---传入含exe可执行程序的绝对路径
#Application(backend="uia").start("C:\\Windows\\System32\\notepad.exe")

#通过connect连接已经打开的应用程序
# Application(backend="uia").connect(process=40068)

# app=Application(backend="uia").start("C:\\Windows\\System32\\notepad.exe")
# #打印程序的进程ID
# print(app.process)
# Application(backend="uia").connect(process=app.process)

#通过句柄的方式连接已经打开的程序
# app=Application(backend="uia").connect(handle=具体数字)

# app=Application("uia").start("E:\\tools\\bit\\Sublime Text\sublime_text.exe")
#
# Application(backend="uia").connect(process=app.process)
#
# app=Application(backend="uia").connect(process=21216)
# win = app.window(title_re='.*Sublime Text .*')
# win.print_control_identifiers()
#打开程序
# app=Application("uia").start("E:\\tools\\bit\\Sublime Text\sublime_text.exe")
# #title进行窗口定位
# win=app.window(title="untitled • - Sublime Text (UNREGISTERED)")
# win.wait("visible")

#class_name进行定位窗口
# win=app.window(class_name="PX_WINDOW_CLASS")
# win.wait('visible')

#正则表达式匹配
# win = app.window(title_re='.*Sublime Text.*')
# win.wait('visible')

# win.print_control_identifiers()--打印得到下面的
# ['untitled • - Sublime Text (UNREGISTERED)Dialog', 'Dialog', 'untitled • - Sublime Text (UNREGISTERED)']
# best_match进行定位--上述的三种任选其一即可

# win=app.window(best_match='Dialog')
# win=app.window(best_match='untitled • - Sublime Text (UNREGISTERED)Dialog')
# win.wait("visible")

app=Application(backend="uia").connect(path="explorer")
app["任务栏"].print_control_identifiers()





